<template>
  <div ref="myDialog" class="dialog">
    <!--遮罩层-->
    <div @click="clickMask" class="mask">
    </div>
    <!--内容层-->
    <div :style="{'top':top}" style="width: 100%;position:absolute;z-index:101;">
      <slot name="content"></slot>
    </div>
  </div>
</template>

<script>
  export default {
    name: "MyDialog",
    props:{
      //此处一定要用value
      value: {
        type:Boolean,
        default:false
      },
      top: {
        type:String,
        default:'10%'
      },
    },
    methods:{
      clickMask(){
        this.$emit('clickMask')
      },
      changeTranslateY(value){
          let myDialog=this.$refs.myDialog
        if(value){
          myDialog.style.transform = 'translateY(0vh)';
        }else{
          myDialog.style.transform = 'translateY(100vh)';
        }
      }
    },
    watch:{
      value(value){
        this.changeTranslateY(value);
      }
    }
  }
</script>

<style scoped>
  .dialog{
    width:100%;
    height:100vh;
    position: fixed;
    top:0;
    left:0;
    z-index:100;
    transform:translateY(100vh);
    transition: transform 0.5s;
    /*animation: maskdonghua 3s;//css动画*/
  }
  .mask{
    width:100%;
    height:100%;
    background:gray;
    position:absolute;
    top:0;
    left:0;
    z-index:100;
    opacity:0.6;
  }
</style>
